package nojava;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 流的基本使用
 */
public class Main {
    public static void main(String[] args) {
        // 排除 <80 , 去重，排序输出
        List<Integer> list = Arrays.asList(418, 434, 418, 852, 45, 254, 41, 63, 754, 965, 254, 45, 68, 77);

//        stream   一气呵成
        Map<Integer, Dog> map = list.stream()
                .filter(i -> i >= 80)
                .distinct()
                .sorted()
//                .map(Dog::new)
                .map(i -> new Dog(i))
                .peek(e -> e.setName("狗" + e.getId()))
                .collect(Collectors.toMap(Dog::getId, e -> e));


        for (Integer key : map.keySet()) {
            System.out.println(key + " ---> " + map.get(key));
        }

      /*  List<Dog> listDog = new ArrayList<>();
        for (Integer id : ids) {
            Dog dog = new Dog().setId(id);
            listDog.add(dog);
        }*/

        // System.out.println(collect);

    }

}
